package com.truyen.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.truyen.persistence.dao.BookmarkChapterDao;
import com.truyen.persistence.entity.Account;
import com.truyen.persistence.entity.BookmarkChapter;
import com.truyen.service.BookmarkChapterService;
import com.truyen.utils.PagingInfo;


@Service
public class BookmarkChapterServiceImpl implements BookmarkChapterService {
	
	@Autowired
	private BookmarkChapterDao bookmarkChapterDao;

	@Override
	public void save(BookmarkChapter entity) {
		bookmarkChapterDao.save(entity);
	}

	@Override
	public BookmarkChapter findById(Long id) {
		return bookmarkChapterDao.findById(id);
	}

	@Override
	public List<BookmarkChapter> getAll() {
		return bookmarkChapterDao.findAll();
	}

	@Override
	@Transactional
	public void delete(long id) {
		try{
			BookmarkChapter bc = findById(id);
			if(bc!=null){
				bookmarkChapterDao.delete(bc);
			}
		}catch(Exception e){
			
		}
	}

	@Override
	public List<BookmarkChapter> getLstByAccountWithPaging(Account account,
			PagingInfo pInfo) {
		return bookmarkChapterDao.getLstByAccountWithPaging(account,pInfo);
	}

	@Override
	public BookmarkChapter findByProperty(String column, Object value) {
		List<BookmarkChapter> lst = bookmarkChapterDao.findByProperty(column, value);
		return (lst.size() > 0) ? lst.get(0) : null;
	}

	@Override
	public BookmarkChapter findByAccountIdTruyenIdChapter(Account account, Long idTruyen,
			Long idChapter) {
		// TODO Auto-generated method stub
		return bookmarkChapterDao.findByAccountIdTruyenIdChapter(account,idTruyen,idChapter);
	}


}
